<!-- Seednia home -->

<style type="text/css">
* { font-family: Verdana; font-size: 96%; }
label { width: 10em; float: left; }
label.error { float: none; color: red; padding-left: .5em; vertical-align: top; }
p { clear: both; }
.submit { margin-left: 12em; }
em { font-weight: bold; padding-right: 1em; vertical-align: top; }
</style>

<?php foreach($milestones as $milestone) { ?>
	<form class="form-horizontal validating-form" id="FormProjectMilestone" name="FormProjectMilestone" 
		  method="post" action="<?php echo WEBCONTEXT; ?>/index.php/Project/editmilestones"   >
		<input type="hidden" id="projectSid" name="projectSid" value="<?php echo $milestone->projectSid; ?>" />
		<?php if (isset($milestone) && isset($milestone->sid)) { ?>
			<input type="hidden" id="sid" name="sid" value="<?php echo $milestone->sid; ?>" />
		<?php } ?>
		<fieldset>
			<legend>Milestone <?php echo Util_Data::getValueOf($milestone, 'name'); ?></legend>
			<div class="control-group">
				<label class="control-label" for="name">Name</label>
				<div class="controls">
					<input type="text" id="name" name="name"  class="required"
						   value="<?php echo Util_Data::getValueOf($milestone, 'name'); ?>" />
				</div>
			</div>
			<div class="control-group">
				<label class="control-label" for="description">Description</label>
				<div class="controls">
					<textarea id="description" name="description" ><?php echo Util_Data::getValueOf($milestone, 'description'); ?></textarea>
				</div>
			</div>
			
			<div class="control-group">
				<label class="control-label" for="priority">Priority</label>
				<div class="controls">
					<?php echo Form::select('priority', array(1,2,3,4,5), Util_Data::getValueOf($milestone, 'priority')); ?>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label" for="planStartDt">Start Date</label>
				<div class="controls">
					<input type="text" id="planStartDt" name="planStartDt" class="datepicker required" data-date-format="<?php echo $sessionInfo->userInfo['dateFormatJs']; ?>" 
						value="<?php echo datetime_format_convert(Util_Data::getValueOf($milestone, 'planStartDt'), FORMAT_DATE_ISO, $sessionInfo->userInfo['dateFormat']); ?>" />
				</div>
			</div>
			<div class="control-group">
				<label class="control-label" for="planFinishDt">End Date</label>
				<div class="controls">
					<input type="text" id="planEndDt" name="planEndDt" class="datepicker" data-date-format="<?php echo $sessionInfo->userInfo['dateFormatJs']; ?>" 
						value="<?php echo datetime_format_convert(Util_Data::getValueOf($milestone, 'planEndDt'), FORMAT_DATE_ISO, $sessionInfo->userInfo['dateFormat']); ?>" />
				</div>
			</div>

			<div class="control-group">
				<div class="controls">
					<button type="submit" class="btn">Update</button>
				</div>
			</div>
		</fieldset>
	</form>
<?php } ?>

<?php 
	$milestone = new stdClass();
	$milestone->projectSid = $projectSid;
?>
	<form class="form-horizontal validating-form" id="FormProjectMilestoneNew" name="FormProjectMilestoneNew" 
			method="post" action="<?php echo WEBCONTEXT; ?>/index.php/Project/editmilestones"   >
		<input type="hidden" id="projectSid" name="projectSid" value="<?php echo $milestone->projectSid; ?>" />
		<fieldset>
			<legend>New Milestone </legend>
			<div class="control-group">
				<label class="control-label" for="name">Name</label>
				<div class="controls">
					<input type="text" id="name" name="name" class="required"
						   value="<?php echo Util_Data::getValueOf($milestone, 'name'); ?>" />
				</div>
			</div>
			<div class="control-group">
				<label class="control-label" for="description">Description</label>
				<div class="controls">
					<textarea id="description" name="description" ><?php echo Util_Data::getValueOf($milestone, 'description'); ?></textarea>
				</div>
			</div>
			
			<div class="control-group">
				<label class="control-label" for="priority">Priority</label>
				<div class="controls">
					<?php echo Form::select('priority', array(1,2,3,4,5), Util_Data::getValueOf($milestone, 'priority')); ?>
				</div>
			</div>
			<div class="control-group">
				<label class="control-label" for="planStartDt">Start Date</label>
				<div class="controls">
					<input type="text" id="planStartDt" name="planStartDt" class="datepicker required" data-date-format="<?php echo $sessionInfo->userInfo['dateFormatJs']; ?>" 
						value="<?php echo datetime_format_convert(Util_Data::getValueOf($milestone, 'planStartDt'), FORMAT_DATE_ISO, $sessionInfo->userInfo['dateFormat']); ?>" />
				</div>
			</div>
			<div class="control-group">
				<label class="control-label" for="planFinishDt">End Date</label>
				<div class="controls">
					<input type="text" id="planEndDt" name="planEndDt" class="datepicker" data-date-format="<?php echo $sessionInfo->userInfo['dateFormatJs']; ?>" 
						value="<?php echo datetime_format_convert(Util_Data::getValueOf($milestone, 'planEndDt'), FORMAT_DATE_ISO, $sessionInfo->userInfo['dateFormat']); ?>" />
				</div>
			</div>

			<div class="control-group">
				<div class="controls">
					<button type="submit" class="btn">Add</button>
				</div>
			</div>
		</fieldset>
	</form>

<script type="text/javascript" src="http://jzaefferer.github.com/jquery-validation/jquery.validate.js"></script>
<script type="text/javascript">
// FYI jQuery: multiple $(document).ready() is possible.
$(document).ready(function() {
	$('.datepicker').datepicker();
	$(".validating-form").validate();
	$("#FormProjectMilestoneNew").validate();
	$('.tags').tagsInput({
		'height':'40px',
		'width':'300px'});
	
});
</script>